Microwave filters GUI  2.0.3
tclAppInit.c
1 /*
2  * tclAppInit.c --
3  *
4  * Provides a default version of the main program and Tcl_AppInit
5  * function for Tcl applications (without Tk).
6  *
7  * Copyright (c) 1993 The Regents of the University of California.
8  * Copyright (c) 1994-1997 Sun Microsystems, Inc.
9  * Copyright (c) 1998-1999 by Scriptics Corporation.
10  *
11  * See the file "license.terms" for information on usage and redistribution of
12  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
13  */
14 
15 #include "tcl.h"
16 
17 #ifdef TCL_TEST
18 
19 #include "tclInt.h"
20 
21 extern Tcl_PackageInitProc Procbodytest_Init;
22 extern Tcl_PackageInitProc Procbodytest_SafeInit;
23 extern Tcl_PackageInitProc TclObjTest_Init;
24 extern Tcl_PackageInitProc Tcltest_Init;
25 
26 #endif /* TCL_TEST */
27 
28 #ifdef TCL_XT_TEST
29 extern void XtToolkitInitialize _ANSI_ARGS_((void));
30 extern int Tclxttest_Init _ANSI_ARGS_((Tcl_Interp *interp));
31 #endif
32 
33 /*
34  *----------------------------------------------------------------------
35  *
36  * main --
37  *
38  * This is the main program for the application.
39  *
40  * Results:
41  * None: Tcl_Main never returns here, so this function never returns
42  * either.
43  *
44  * Side effects:
45  * Whatever the application does.
46  *
47  *----------------------------------------------------------------------
48  */
49 
50 int
51 main(
52  int argc, /* Number of command-line arguments. */
53  char **argv) /* Values of command-line arguments. */
54 {
55  /*
56  * The following #if block allows you to change the AppInit function by
57  * using a #define of TCL_LOCAL_APPINIT instead of rewriting this entire
58  * file. The #if checks for that #define and uses Tcl_AppInit if it does
59  * not exist.
60  */
61 
62 #ifndef TCL_LOCAL_APPINIT
63 #define TCL_LOCAL_APPINIT Tcl_AppInit
64 #endif
65  extern int TCL_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp));
66 
67  /*
68  * The following #if block allows you to change how Tcl finds the startup
69  * script, prime the library or encoding paths, fiddle with the argv,
70  * etc., without needing to rewrite Tcl_Main()
71  */
72 
73 #ifdef TCL_LOCAL_MAIN_HOOK
74  extern int TCL_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv));
75 #endif
76 
77 #ifdef TCL_XT_TEST
78  XtToolkitInitialize();
79 #endif
80 
81 #ifdef TCL_LOCAL_MAIN_HOOK
82  TCL_LOCAL_MAIN_HOOK(&argc, &argv);
83 #endif
84 
85  Tcl_Main(argc, argv, TCL_LOCAL_APPINIT);
86 
87  return 0; /* Needed only to prevent compiler warning. */
88 }
89 
90 /*
91  *----------------------------------------------------------------------
92  *
93  * Tcl_AppInit --
94  *
95  * This function performs application-specific initialization. Most
96  * applications, especially those that incorporate additional packages,
97  * will have their own version of this function.
98  *
99  * Results:
100  * Returns a standard Tcl completion code, and leaves an error message in
101  * the interp's result if an error occurs.
102  *
103  * Side effects:
104  * Depends on the startup script.
105  *
106  *----------------------------------------------------------------------
107  */
108 
109 int
110 Tcl_AppInit(
111  Tcl_Interp *interp) /* Interpreter for application. */
112 {
113  if (Tcl_Init(interp) == TCL_ERROR) {
114  return TCL_ERROR;
115  }
116 
117 #ifdef TCL_TEST
118 #ifdef TCL_XT_TEST
119  if (Tclxttest_Init(interp) == TCL_ERROR) {
120  return TCL_ERROR;
121  }
122 #endif
123  if (Tcltest_Init(interp) == TCL_ERROR) {
124  return TCL_ERROR;
125  }
126  Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init,
127  (Tcl_PackageInitProc *) NULL);
128  if (TclObjTest_Init(interp) == TCL_ERROR) {
129  return TCL_ERROR;
130  }
131  if (Procbodytest_Init(interp) == TCL_ERROR) {
132  return TCL_ERROR;
133  }
134  Tcl_StaticPackage(interp, "procbodytest", Procbodytest_Init,
135  Procbodytest_SafeInit);
136 #endif /* TCL_TEST */
137 
138  /*
139  * Call the init functions for included packages. Each call should look
140  * like this:
141  *
142  * if (Mod_Init(interp) == TCL_ERROR) {
143  * return TCL_ERROR;
144  * }
145  *
146  * where "Mod" is the name of the module. (Dynamically-loadable packages
147  * should have the same entry-point name.)
148  */
149 
150  /*
151  * Call Tcl_CreateCommand for application-specific commands, if they
152  * weren't already created by the init functions called above.
153  */
154 
155  /*
156  * Specify a user-specific startup file to invoke if the application is
157  * run interactively. Typically the startup file is "~/.apprc" where "app"
158  * is the name of the application. If this line is deleted then no user-
159  * specific startup file will be run under any conditions.
160  */
161 
162 #ifdef DJGPP
163  Tcl_SetVar(interp, "tcl_rcFileName", "~/tclsh.rc", TCL_GLOBAL_ONLY);
164 #else
165  Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclshrc", TCL_GLOBAL_ONLY);
166 #endif
167 
168  return TCL_OK;
169 }
170 
171 /*
172  * Local Variables:
173  * mode: c
174  * c-basic-offset: 4
175  * fill-column: 78
176  * End:
177  */
178 
179